#include <bits/stdc++.h>
using namespace std;
#define int long long

int a, b, c;

long long qpow(long long a, long long b, long long p) {
	long long res = 1;
	while (b) {
		if (b & 1) res = res * a % p;
		a = a * a % p;
		b >>= 1;
	}
	return res;
}

int ps[5] = {998244353, (int)1e9+7, (int)1e9+9, 147744151, 998244853};

bool chk(int x, int y, int z) {
	for (int i = 0; i < 5; ++i) {
		if (qpow(y, x, ps[i]) != qpow(x, z, ps[i])) return 0;
	}
	return 1;
}


void solve() {
	cin >> a >> b >> c;
	if (a <= 100 && b <= 100 && c <= 100) {
		int res = 0;
		for (int x = 1; x <= a; ++x) {
			for (int y = 1; y <= b; ++y) {
				for (int z = 1; z <= c; ++z) {
					if (chk(x, y, z)) {
						++res;
					}
				}
			}
		}
	cout << res << "\n";
	}
}

signed main() {
	freopen("alien.in", "r", stdin);
	freopen("alien.out", "w", stdout);
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int tc; cin >> tc; while (tc--) solve(); return 0;

}
